package com.kitty.game.fight.hunqi.passive;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.FieldValuePosConst;
import com.kitty.game.equip.model.RoleEquip;
import com.kitty.game.equip.service.EquipService;
import com.kitty.game.fight.bean.Fight;
import com.kitty.game.fight.bean.FightObject;
import com.kitty.game.fight.message.RespAttackSkillLightEffect;
import com.kitty.game.fight.service.FightMessageService;
import com.kitty.game.fight.util.FightMessageUtil;
import com.kitty.game.utils.Const;

public class LunHuiHunQiEffect extends  HunQiEffect{
    @Override
    public short getEffectId() {
        return 0;
    }

    @Override
    public Object trigger(Fight fight, FightObject effector, Object... params) {
        //是否是人物   被攻击方
        if (!effector.isPlayer()) {
            return false;
        }
        if (SpringUtils.getHunQiService().getSpecialSkillId(effector) != Const.HUNQILUNHUI) {
            return Boolean.FALSE;
        }
        RespAttackSkillLightEffect respAttackSkillLightEffect = new RespAttackSkillLightEffect();
        respAttackSkillLightEffect.setId(effector.getId());
        respAttackSkillLightEffect.setEffectId((short)0);
        respAttackSkillLightEffect.setType(4);//天书4 其他0
        respAttackSkillLightEffect.setName("轮回");
        FightMessageUtil.sendFightPackage(fight,respAttackSkillLightEffect);
        //恢复血量
        EquipService equipService = SpringUtils.getEquipService();
        RoleEquip hunqi = equipService.getRoleEquipByPos(effector.getRole(), Const.TALISMAN);
        int hunQiCoung = getHunQiCount(hunqi);
        FightMessageService fightMessageService = SpringUtils.getFightMessageService();
        FightMessageUtil.sendFightPackage(fight,
                fightMessageService.decreaseLife(effector.getId(), effector.getId(), hunQiCoung, 4098, 10005));
        effector.setCurrLife(effector.getCurrLife() + hunQiCoung);
        FightMessageUtil.sendFightPackage(fight, fightMessageService.updateTargetLife(effector.getId(), effector.getCurrLife()));

        return true;
    }

    @Override
    public int getHunQiCount(RoleEquip hunqi) {
        int specialSkillLevel = hunqi.getEquipValue(FieldValuePosConst.HUNQI_SKILL_LEVEL);
        int life =(int)( getHunQiSkillValue(hunqi.queryLevel())  * 4 * specialSkillLevel /5);
        return life;
    }

    public static void main(String[] args) {
        System.out.println((int)( getHunQiSkillValue(74)  * 4 * 1 /5));
    }
}
